/**
 * Copyright (C) 2016 Eshore Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.eshore.thrpc.test.thrift;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;

import com.eshore.thrpc.test.gen.EchoService.Client;

/**
 * <p>
 * 
 * @author : zhouzhixiang
 * @date : 2015-6-10
 */
public class ThriftMain {
    public static void main(String[] args) {
//        TSocket transport = new TSocket("127.0.0.1", 19090);
        TFramedTransport framedtransport = new TFramedTransport(new TSocket("127.0.0.1", 19090,3000));
        TProtocol protocol = new TBinaryProtocol(framedtransport);
        Client client = new Client(protocol);

        try {
//            transport.open();
        	framedtransport.open();
            long startTime = System.currentTimeMillis();
            for (int i = 0; i < 10; i++) {
                System.out.println(client.echo("hello world!"));
            }
            System.out.println(System.currentTimeMillis() - startTime);
        } catch (TException e) {
        	e.printStackTrace();
        }
    }
}
